import './assets/main.css'

import { createApp } from 'vue'
import ElementPlus from 'element-plus'
import App from './App.vue'
import router from './router'
import Globe from './components/Globe.vue' 
import 'element-plus/dist/index.css'
import VueQr from 'vue-qr'





//前置路由守卫
router.beforeEach((to, from, next) => {

  console.log("========前置路由守卫======================");
  console.log(to.path);
  console.log("=======================");  
  if (to.path==='/login') {
    return next();
  }
  const token= sessionStorage.getItem('token')
  if (!token) {
    return next('/login');
  }
  //如果已经登录，则直接跳转
  next()
})

const app = createApp(App)
app.component('Globe', Globe)
app.use(router)
app.use(ElementPlus)
app.use(VueQr)
app.mount('#app')
